import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { downloadSysFile } from '@/utils/download-util';
const basePath = '/demo/template/demomainnests';
/** 主子表嵌套示例-主表 */
export interface FormDataDto extends BaseBeanModel {
  id?: string;
  formStep1?: DemoMainNestDto;
  formStep2?: DemoMainNestDto;
  formStep3?: DemoMainNestDto;
}
export interface DemoMainNestDto extends BaseBeanModel {
  /** 用户 */
  demoUserId?: string;
  demoUserIdAlias?: string;
  /** 部门 */
  demoDeptId?: string;
  demoDeptIdAlias?: string;
  /** 角色 */
  demoRoleId?: string;
  demoRoleIdAlias?: string;
  /** 群组 */
  demoGroupId?: string;
  demoGroupIdAlias?: string;
  /** 岗位 */
  demoPositionId?: string;
  demoPositionIdAlias?: string;
  /** 单选 */
  demoRadio?: string;
  demoRadioName?: string;
  /** 单选（按钮） */
  demoRadioButton?: string;
  demoRadioButtonName?: string;
  /** 复选 */
  demoCheckbox?: any;
  /** 下拉 */
  demoSelect?: any;
  /** 下拉多选 */
  demoSelectMultiple?: any;
  /** 密级 */
  secretLevel?: any;
  /** 开关 */
  demoSwitch?: any;
  /** 小数 */
  demoNumber?: number;
  /** 整数 */
  demoInteger?: number;
  /** 日期 */
  demoDate?: any;
  demoDateBegin?: any;
  demoDateEnd?: any;
  /** 日期时间 */
  demoDateTime?: any;
  demoDateTimeBegin?: any;
  demoDateTimeEnd?: any;
  /** 必填 */
  demoNotnull?: string;
  /** 多行文本 */
  demoTextarea?: string;
  /** 编码 */
  demoCode?: any;
  /** 电话(正则) */
  demoPhone?: string;
  /** 邮箱(正则) */
  demoEmail?: string;
  /** 网址(正则) */
  demoWebsite?: string;
  /** 唯一值 */
  demoUnique?: string;
  /** 弹窗 */
  demoModalSelect?: string;
  demoModalSelectAlias?: string;
  /** 背景样式 */
  demoBackgroundColor?: string;
  /** 富文本 */
  demoRichtext?: string;
  /** 测试文本 */
  demoText2?: string;
  /** 子表集合 */
  demoSubNestList?: [];
}

/** 获取分页数据 */
export function listDemoMainNestByPage(param: QueryParamModel): Promise<ResponsePageData<DemoMainNestDto>> {
  return request.post(`${basePath}/find-list-by-page/v1`, param);
}

/** 根据id加载数据 */
export function getDemoMainNest(id: string): Promise<ResponseBaseData<DemoMainNestDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/** 保存表单数据 */
export function saveDemoMainNest(form: DemoMainNestDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/** 根据id集合删除数据 */
export function delDemoMainNest(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}

/** 更新开关 */
export function updateDemoSwitch(id: string, demoSwitch: string): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/update-demo-switch/v1/${id}/${demoSwitch}`);
}

/** 校验唯一值唯一性 */
export function checkDemoUniqueUnique(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/check-demo-unique-unique/v1`, param);
}

/** 导出Excel */
export function exportExcel(param: any) {
  const download = {
    url: `${basePath}/export-data/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return downloadSysFile(download);
}
